/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.session;

import com.thienloc.omap.entity.LotterySchedule;
import java.util.List;
import org.slf4j.LoggerFactory;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

/**
 *
 * @author GiangLT
 */
@Stateless
public class LotteryScheduleFacade extends AbstractFacade<LotterySchedule> {

    @PersistenceContext(unitName = "omapPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public LotteryScheduleFacade() {
        super(LotterySchedule.class);
    }

    public List<LotterySchedule> findByDayOfWeek(Integer dayOfWeek) {
        try {
            TypedQuery<LotterySchedule> q = em.createNamedQuery("LotterySchedule.findByDayOfWeek", LotterySchedule.class);
            q.setParameter("dayOfWeek", dayOfWeek);
            List<LotterySchedule> result = q.getResultList();
            return result;
        } catch (NoResultException ex) {
            return null;
        } catch (Exception ex) {
            LoggerFactory.getLogger(LotteryScheduleFacade.class.getName()).error("", ex);
            return null;
        }
    }
}
